/*
 * net_opration.h
 *
 *  Created on: 2012-7-5
 *      Author: ThinkPad
 */

#ifndef NET_OPRATION_H_
#define NET_OPRATION_H_

#include "connect_pool.h"

/*
*next opration
*/
enum NEXT_OPRATION
{
        DO_INVALID,
        DO_RECV,
        DO_SEND,
        DO_TRANSFILE,
        DO_WAIT,
        DO_CLOSE
};

/*net operation data*/
struct io_opration
{
        NETPROTOCL   net_protocl;
        user_token * token;

        io_opration()
        {
                net_protocl = NET_TCP;
                token = NULL;
        }
};


class net_opration
{
public:
	  net_opration();
	  ~net_opration();

	  int init_queue(int size = DFLT_MIN_CONN_SIZ);
	  int op_enqueue(NETPROTOCL net_protocl,user_token * token);
	  int op_dequeue(NETPROTOCL *net_protocl,user_token ** token);
	  int get_opration_count(void);

protected:
	  io_opration * op;
	  stack<io_opration *> free_opration;
	  queue<io_opration *> queue_opration;
	  int m_count;
	  smart_lock   op_lock;

private:
	  int  op_queue_size;
};

#endif /* NET_OPRATION_H_ */
